<template>
  <div class="home" style="height: 100%">
    <el-container style="height: 100vh; ">
      <el-aside width="200px" height="100%" style="background-color: rgb(238, 241, 246)">
    <Aside />
     </el-aside>

      <el-container>
        <el-header style="text-align: right; font-size: 12px; border-bottom: 1px solid #ccc;line-height: 60px;">
        <Header :user="user" />
        </el-header>

        <el-main>
         <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import Header from "@/components/Header";
import Aside from "@/components/Aside";

export default {

  components:{
    Aside,
    Header
  },
  data(){
    return{
      user:{}
    }
  },
  created() {
    // 从后台获取最新的User数据
    this.getUser()
  },
  methods:{
    getUser() {
      let realname = localStorage.getItem("user") ? JSON.parse(localStorage.getItem("user")).realname : ""
      if (realname) {
        // 从后台获取User数据
        this.request.get("/user/realname/" + realname).then(res => {
          // 重新赋值后台的最新User数据
          this.user = res.data
        })
      }
    }
  }
}
</script>

<style>

</style>
